import QtQuick
import QtQuick.Controls

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    Column {
        anchors.fill: parent

        SwipeView {
            id: swipeView
            anchors.fill: parent
            currentIndex: pageIndicator.currentIndex

            Repeater {
                model: 5
                Page {
                    Label {
                        text: "Page " + (index + 1)
                        anchors.centerIn: parent
                    }
                }
            }
        }

PageIndicator {
    id: pageIndicator
    interactive: true  // 启用点击跳转
    anchors {
        bottom: parent.bottom
        horizontalCenter: parent.horizontalCenter
        bottomMargin: 20
    }
    count: swipeView.count
    currentIndex: swipeView.currentIndex

    // 动态调整可见性
    visible: count > 1

    delegate: Column {
        spacing: 5

        Rectangle {
            width: 12
            height: 12
            radius: 6
            color: index === swipeView.currentIndex ? "green" : "gray"
        }

        Text {
            text: index + 1
            color: "#333"
            font.bold: true
            anchors.horizontalCenter: parent.horizontalCenter
        }
    }
}
    }
}
